package c.j.a.a.a.e;

import android.text.TextUtils;
import com.bytedance.embedapplog.AppLog;
import java.util.Iterator;
import java.util.List;
import org.json.JSONObject;

/* compiled from: DownloadEventModel */
public class d {
    public String a;
    public final String b;
    public final String c;
    public final boolean d;
    public final long e;
    public final String f;
    public final long g;
    public final JSONObject h;
    public final List<String> i;
    public final int j;
    public final Object k;
    public final boolean l;
    public final String m;
    public final JSONObject n;

    /* compiled from: DownloadEventModel */
    public static class a {
        public String a;
        public String b;
        public String c;
        public boolean d = false;
        public long e;
        public String f;
        public long g;
        public JSONObject h;
        public List<String> i;
        public int j;
        public Object k;
        public String l;
        public boolean m = false;
        public String n;
        public JSONObject o;

        public d a() {
            if (TextUtils.isEmpty(this.a)) {
                this.a = AppLog.UMENG_CATEGORY;
            }
            JSONObject jSONObject = new JSONObject();
            if (this.h == null) {
                this.h = new JSONObject();
            }
            try {
                String str = "1";
                String str2 = "is_ad_event";
                String str3 = "refer";
                String str4 = "log_extra";
                if (this.m) {
                    this.n = this.c;
                    this.o = new JSONObject();
                    Iterator keys = this.h.keys();
                    while (keys.hasNext()) {
                        String str5 = (String) keys.next();
                        this.o.put(str5, this.h.get(str5));
                    }
                    this.o.put("category", this.a);
                    this.o.put("tag", this.b);
                    this.o.put("value", this.e);
                    this.o.put("ext_value", this.g);
                    if (!TextUtils.isEmpty(this.l)) {
                        this.o.put(str3, this.l);
                    }
                    if (this.d) {
                        if (!(this.o.has(str4) || TextUtils.isEmpty(this.f))) {
                            this.o.put(str4, this.f);
                        }
                        this.o.put(str2, str);
                    }
                }
                if (this.d) {
                    jSONObject.put("ad_extra_data", this.h.toString());
                    if (!(jSONObject.has(str4) || TextUtils.isEmpty(this.f))) {
                        jSONObject.put(str4, this.f);
                    }
                    jSONObject.put(str2, str);
                } else {
                    jSONObject.put("extra", this.h);
                }
                if (!TextUtils.isEmpty(this.l)) {
                    jSONObject.putOpt(str3, this.l);
                }
                this.h = jSONObject;
            } catch (Exception unused) {
            }
            return new d(this);
        }
    }

    public d(a aVar) {
        this.a = aVar.a;
        this.b = aVar.b;
        this.c = aVar.c;
        this.d = aVar.d;
        this.e = aVar.e;
        this.f = aVar.f;
        this.g = aVar.g;
        this.h = aVar.h;
        this.i = aVar.i;
        this.j = aVar.j;
        this.k = aVar.k;
        this.l = aVar.m;
        this.m = aVar.n;
        this.n = aVar.o;
    }

    public String toString() {
        StringBuilder g = c.b.a.a.a.g("category: ");
        g.append(this.a);
        g.append("\ttag: ");
        g.append(this.b);
        g.append("\tlabel: ");
        g.append(this.c);
        g.append("\nisAd: ");
        g.append(this.d);
        g.append("\tadId: ");
        g.append(this.e);
        g.append("\tlogExtra: ");
        g.append(this.f);
        g.append("\textValue: ");
        g.append(this.g);
        g.append("\nextJson: ");
        g.append(this.h);
        g.append("\nclickTrackUrl: ");
        List list = this.i;
        String str = "";
        g.append(list != null ? list.toString() : str);
        g.append("\teventSource: ");
        g.append(this.j);
        g.append("\textraObject: ");
        Object obj = this.k;
        g.append(obj != null ? obj.toString() : str);
        g.append("\nisV3: ");
        g.append(this.l);
        g.append("\tV3EventName: ");
        g.append(this.m);
        g.append("\tV3EventParams: ");
        JSONObject jSONObject = this.n;
        if (jSONObject != null) {
            str = jSONObject.toString();
        }
        g.append(str);
        return g.toString();
    }
}
